/*
 * RTSAI - Real-Time Strategy engine for AI research
 * Copyright(C) 2006 DIMAp-UFRN, licensed under LGPL
 *
 * GameView declarations
 */

#ifndef GAMEVIEW_H
#define GAMEVIEW_H

#include "OpenSteer/Vec3.h"
#include "OpenSteer/Clock.h"
#include "OpenSteer/Camera.h"
#include "OpenSteer/Utilities.h"

#include "Common.h"

using OpenSteer :: Clock;
using OpenSteer :: Camera;
using OpenSteer :: AbstractVehicle;
using OpenSteer :: Vec3;

typedef void ( *ViewCallback ) ();

class GameView
{
    public:
        GameView();
        virtual ~GameView();

        static void init (int argc, char **argv, ViewCallback view_update);
        static void start_loop();

        static void update();

        static void logical_update();

        // drawing methods -----------------------------------------------------
        static void drawVehicle (const Unit& unit, const Vector3D& color);
        static void drawObject (const GameObject& obj, const Vector3D& color);

        // static attributes ---------------------------------------------------
        /// clock keeps track of both "real time" and "simulation time"
        static Clock clock;

        /// camera automatically tracks selected vehicle
        static Camera camera;

        ///  currently selected vehicle.  Generally the one the camera follows
        static const AbstractVehicle* selectedVehicle;

        // for storing most recent mouse state
        static int mouseX;
        static int mouseY;
        static bool mouseInWindow;

    private:

    static ViewCallback visualization_update;

    // camera utilities --------------------------------------------------------
    // some camera-related default constants
    static const float camera2dElevation = 8;
    static const float cameraTargetDistance = 13;
    static const Vec3 cameraTargetOffset;

    // set a certain initial camera state used by several plug-ins
    static void init2dCamera (AbstractVehicle& selected,
                              float distance = cameraTargetDistance,
                              float elevation = camera2dElevation);
    static void init3dCamera (AbstractVehicle& selected,
                              float distance = cameraTargetDistance,
                              float elevation = camera2dElevation);

    // set initial position of camera based on a vehicle
    static void position3dCamera (AbstractVehicle& selected,
                              float distance = cameraTargetDistance,
                              float elevation = camera2dElevation);
    static void position2dCamera (AbstractVehicle& selected,
                              float distance = cameraTargetDistance,
                              float elevation = camera2dElevation);

    // camera updating utility
    static void updateCamera (const float currentTime,
                              const float elapsedTime,
                              const AbstractVehicle& selected);

    // ground plane grid-drawing utility
    static void gridUtility (const Vec3& gridTarget);
};

#endif // GAMEVIEW_H
